class_name DamageReductionEffect
extends Effect

var reduction_amount := 1

func execute(targets: Array[Node]) -> void:
	for target in targets:
		if not target:
			continue
		if target is Enemy or target is Player:
			# 使用ModifierHandler系统添加伤害减少修改
			var dmg_taken_modifier: Modifier = target.modifier_handler.get_modifier(Modifier.Type.DMG_TAKEN)
			if dmg_taken_modifier:
				# 创建固定减少修改值
				var reduction_modifier_value := ModifierValue.create_new_modifier(
					"damage_reduction_effect", 
					ModifierValue.Type.FLAT
				)
				reduction_modifier_value.flat_value = -reduction_amount  # 减少1点伤害
				
				# 添加修改器
				dmg_taken_modifier.add_new_value(reduction_modifier_value)
				print("🛡️ %s 获得伤害减少效果：所有伤害-1" % target.name)
				
				if sound:
					SFXPlayer.play(sound) 
